package com.hxd.otc.module.wallet.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.base.BaseRecyclerPresenter;
import com.hxd.otc.module.wallet.adapter.CurrencyConverterAdapter;
import com.hxd.otc.module.wallet.bean.WalletCoinRateVoBean;
import com.hxd.otc.module.wallet.contract.CurrencyConverterContract;
import com.hxd.otc.module.wallet.model.WalletModel;
import com.hxd.otc.net.BaseObserver;

import java.util.List;

/**
 * 包  名 :  com.hxd.wcb.client.module.wallet.presenter
 * 类  名 :  CurrencyConverterPresenter
 * 作  者 :  胡庆岭
 * 时  间 :  2018/7/23 9:44
 * 描  述 :  ${汇率换算P}
 */
public class CurrencyConverterPresenter extends BaseRecyclerPresenter<CurrencyConverterContract.View, CurrencyConverterAdapter, WalletCoinRateVoBean> implements CurrencyConverterContract.Presenter {
    private final WalletModel mModel;

    public CurrencyConverterPresenter(CurrencyConverterContract.View view) {
        super(view);
        mModel = new WalletModel();
    }

    @Override
    public void loadData(final boolean isRefresh) {
        mModel.legalTendeDeal(new BaseObserver<List<WalletCoinRateVoBean>>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull List<WalletCoinRateVoBean> data) {
                WalletCoinRateVoBean coinRateVoBean = new WalletCoinRateVoBean();
                coinRateVoBean.setQuotation(1.0000);
                coinRateVoBean.setTransactionPair("CNY/CNY");
                data.add(0, coinRateVoBean);
                mView.onLoadDataSuccess(isRefresh, data);
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean<List<WalletCoinRateVoBean>>>bindAutoDispose());
    }
}
